{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Running Pretrained ImageNet: the Easy way\n",
      "=========================================\n",
      "\n",
      "For easier use of pretrained models, we provide a wrapper specifically written for the case of ImageNet, so one can take an image and directly compute features or predictions from them. Both Python and Matlab wrappers are provided. We will describe the use of the Python wrapper here, and the Matlab wrapper usage is very similar.\n",
      "\n",
      "We assume that you have successfully compiled Caffe and set the correct `PYTHONPATH`. If not, please refer to the [installation instructions](installation.html). You will use our pre-trained imagenet model, which you can download (232.57MB) by running `examples/imagenet/get_caffe_reference_imagenet_model.sh`. Note that this pre-trained model is licensed for academic research / non-commercial use only.\n",
      "\n",
      "Ready? Let's start."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from caffe import imagenet\n",
      "from matplotlib import pyplot\n",
      "\n",
      "# Set the right path to your model file, pretrained model,\n",
      "# and the image you would like to classify.\n",
      "MODEL_FILE = 'imagenet/imagenet_deploy.prototxt'\n",
      "PRETRAINED = 'imagenet/caffe_reference_imagenet_model'\n",
      "IMAGE_FILE = 'images/cat.jpg'"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Loading a network is easy. imagenet.ImagenetClassifier wraps everything. In default, the classifier will crop the center and corners of an image, as well as their mirrored versions, thus creating a batch of 10 images. If you look at the provided MODEL_FILE you can actually see that we are defining the input batch size to be 10.\n",
      "\n",
      "If you would like to just do the center, you need to specify center_only=1, and also change the batch size from 10 to 1 in the prototxt."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "net = imagenet.ImageNetClassifier(\n",
      "    MODEL_FILE, PRETRAINED)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 2
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "We will set the phase to test since we are doing testing, and will first use CPU for the computation."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "net.caffenet.set_phase_test()\n",
      "net.caffenet.set_mode_cpu()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "So now, we can do a prediction. Let's show some output as well:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "prediction = net.predict(IMAGE_FILE)\n",
      "print 'prediction shape:', prediction.shape\n",
      "pyplot.plot(prediction)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "prediction shape: (1000,)\n"
       ]
      },
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 4,
       "text": [
        "[<matplotlib.lines.Line2D at 0x8400dd0>]"
       ]
      },
      {
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEACAYAAAC+gnFaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGp5JREFUeJzt3X9w1OWBx/HP0uycHfyBUOTHbmwkCewiJNImUOSYSVXI\ngZoKOm2qg16bgwwdqvVs9Z/rCM5UzFhu/JHpXMqItepFbsYZ44+41VS3KgJ7Cj20wTOhybgsRjkl\nAlEJ2Tz3x5KFfBM2u8kmG/Z5v2Z2st/9Ps+zzz7ZfD/7fH9sXMYYIwCAtSZkugMAgMwiCADAcgQB\nAFiOIAAAyxEEAGA5ggAALDdkEAQCAfl8PhUWFqqmpmbA+oaGBhUXF2vBggX67ne/q9deey3pugCA\nzHMluo4gGo1qzpw5ampqksfjUWlpqerr6+X3++Nlurq6NHHiREnSe++9p1WrVqm1tTWpugCAzEs4\nIwiFQiooKFBeXp7cbrcqKyvV0NDQr0xfCEjS8ePH9a1vfSvpugCAzEsYBJFIRLm5ufFlr9erSCQy\noNxzzz0nv9+vFStW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vdxuv1mm3btg3rtb/zzjtm3rx5Jj8/3/z85z9P\n6rm5oAwALMe/qgQAyxEEAGA5ggAALEcQAIDlCAIAsBxBAACWIwgAwHIEAQBY7v8BOcxt3c2Qt0YA\nAAAASUVORK5CYII=\n",
       "text": [
        "<matplotlib.figure.Figure at 0x3cb8350>"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "You can see that the prediction is 1000-dimensional, and is pretty sparse.\n",
      "\n",
      "Our pretrained model uses the synset ID ordering of the classes, as listed in `../data/ilsvrc12/synset_words.txt` if you fetch the auxiliary imagenet data by `../data/ilsvrc12/get_ilsvrc_aux.sh`. If you look at the top indices that maximize the prediction score, they are foxes, cats, and other cute mammals. Not unreasonable predictions, right?\n",
      "\n",
      "Now, why don't we see how long it takes to perform the classification end to end? This result is run from an Intel i5 CPU, so you may observe some performance differences."
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%timeit net.predict(IMAGE_FILE)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "1 loops, best of 3: 296 ms per loop\n"
       ]
      }
     ],
     "prompt_number": 5
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "It may look a little slow, but note that it also includes image loading, cropping, and python interfacing time, and it is running 10 images. As a performance notice, if you really want to make prediction fast, you can optionally write things in C and also pipeline the image loading part. But for most applications, the current speed might be fine I guess?\n",
      "\n",
      "OK, so how about GPU? it is actually pretty easy:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "net.caffenet.set_mode_gpu()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Voila! Now we are in GPU mode. Let's see if the code gives the same result:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "prediction = net.predict(IMAGE_FILE)\n",
      "print 'prediction shape:', prediction.shape\n",
      "pyplot.plot(prediction)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "prediction shape: (1000,)\n"
       ]
      },
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 7,
       "text": [
        "[<matplotlib.lines.Line2D at 0x8771110>]"
       ]
      },
      {
       "metadata": {},
       "output_type": "display_data",
       "png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEACAYAAAC+gnFaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAGp5JREFUeJzt3X9w1OWBx/HP0uycHfyBUOTHbmwkCewiJNImUOSYSVXI\ngZoKOm2qg16bgwwdqvVs9Z/rCM5UzFhu/JHpXMqItepFbsYZ44+41VS3KgJ7Cj20wTOhybgsRjkl\nAlEJ2Tz3x5KFfBM2u8kmG/Z5v2Z2st/9Ps+zzz7ZfD/7fH9sXMYYIwCAtSZkugMAgMwiCADAcgQB\nAFiOIAAAyxEEAGA5ggAALDdkEAQCAfl8PhUWFqqmpmbA+oaGBhUXF2vBggX67ne/q9deey3pugCA\nzHMluo4gGo1qzpw5ampqksfjUWlpqerr6+X3++Nlurq6NHHiREnSe++9p1WrVqm1tTWpugCAzEs4\nIwiFQiooKFBeXp7cbrcqKyvV0NDQr0xfCEjS8ePH9a1vfSvpugCAzEsYBJFIRLm5ufFlr9erSCQy\noNxzzz0nv9+vFStW6JFHHkmpLgAgsxIGgcvlSqqRG264Qfv379cLL7ygNWvWiG+tAIBzR06ilR6P\nR+FwOL4cDofl9XrPWn7p0qXq6enR559/Lq/Xm1TdgoICHThwYDh9BwBr5efnq7W1NT2NmQROnjxp\nZs2aZdra2syJEydMcXGxaW5u7lemtbXV9Pb2GmOMeffdd82sWbOSrnvqQHWiLljl3nvvzXQXxg3G\n4jTG4jTG4rR0bjsTzghycnJUW1ur8vJyRaNRVVVVye/3q66uTpJUXV2tZ599Vn/84x/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oIg2YvVss3x48d144036uGHH9YFfVdhneJyuRKOS7aM2YsvvqhLLrlECxYsOOvFiLaMRU9Pj/bs\n2aOf/exn2rNnjyZOnKgHHnigXxlbxuLAgQN66KGH1N7erkOHDun48eN66qmn+pWxZSwGM9RrH4mM\nBYHH41E4HI4vh8PhfkmWjU6ePKkbb7xRa9as0Q033CAplvIdp/5t2Mcff6xLTl1j7hyfgwcPyuPx\njH2nR8Hbb7+t559/Xpdddpl+/OMf67XXXtOaNWusHAuv1yuv16vS0lJJ0k033aQ9e/Zo+vTp1o3F\nO++8oyuvvFJTpkxRTk6OVq9erZ07d1o5Fn1S+Zvwer3yeDw6ePBgv8eTGZOMBcGZF6t1d3dr+/bt\nqqioyFR3Rp0xRlVVVZo7d65+8YtfxB+vqKjQE088IUl64okn4gFRUVGhZ555Rt3d3Wpra1NLS4sW\nLlyYkb6n2/33369wOKy2tjY988wzuuqqq/Tkk09aORbTp09Xbm6uPjz15VBNTU26/PLLdf3111s3\nFj6fT7t27dJXX30lY4yampo0d+5cK8eiT6p/E9OnT9eFF16o3bt3yxijJ598Ml4noXQc4BiuxsZG\nM3v2bJOfn2/uv//+THZl1L355pvG5XKZ4uJic8UVV5grrrjCvPzyy+azzz4zV199tSksLDTLli0z\nR44cidf5zW9+Y/Lz882cOXNMIBDIYO9HTzAYjJ81ZOtY/PWvfzUlJSWmqKjIrFq1ynR2dlo7FjU1\nNWbu3Llm3rx55tZbbzXd3d3WjEVlZaWZMWOGcbvdxuv1mm3btg3rtb/zzjtm3rx5Jj8/3/z85z9P\n6rm5oAwALMe/qgQAyxEEAGA5ggAALEcQAIDlCAIAsBxBAACWIwgAwHIEAQBY7v8BOcxt3c2Qt0YA\nAAAASUVORK5CYII=\n",
       "text": [
        "<matplotlib.figure.Figure at 0x30be2d0>"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Good, everything is the same. And how about time consumption? The following benchmark is obtained on the same machine with a K20 GPU:"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "%timeit net.predict(IMAGE_FILE)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "10 loops, best of 3: 123 ms per loop\n"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Pretty fast right? Not as fast as you expected? Indeed, in this python demo you are seeing only 4 times speedup. But remember - the GPU code is actually very fast, and the data loading, transformation and interfacing actually start to take **more** time than the actual convnet computation itself!\n",
      "\n",
      "To fully utilize the power of GPUs, you really want to use one of these ideas:\n",
      "* Use larger batches, and minimize python call and data transfer overheads.\n",
      "* Pipeline data load operations, like using a subprocess.\n",
      "* Code in C++. A little inconvenient, but maybe worth it if your dataset is really, really large."
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "Parting Words\n",
      "-------------\n",
      "\n",
      "So this is python! We hope the interface is easy enough for one to use. The python wrapper is interfaced with boost::python, and source code can be found at `python/caffe` while the ImageNet wrapper used here is at `python/caffe/imagenet`. If you would like to achieve some custom functions, you are more than welcome to look at them!"
     ]
    }
   ],
   "metadata": {}
  }
 ]
}